<%@include file="/WEB-INF/pages/commons/commons.jsp" %>

<stripes:layout-render name="${_themePath}/basic-space-layout.jsp" _title="Space [${actionBean.space.name}]">

    <stripes:layout-component name="_head">
        <c:out value="${_head}" escapeXml="false"/>
        <meta name="_uniquePageId_" content="_space_" />
        <script type="text/javascript">
            // === spaceHeaderMenu
                YAHOO.util.Event.onContentReady("spaceHeaderMenu", function() {
                    var manageHeaderMenu = new YAHOO.widget.Button("spaceHeaderMenuButton",
                                            { type: "menu", menu: "spaceHeaderMenuButtonSelect" });
                    //	"click" event listener for the second Button's Menu instance
                    var onMenuClick = function (p_sType, p_aArgs) {
                        var oEvent = p_aArgs[0];	//	DOM event
                        var oMenuItem = p_aArgs[1];	//	MenuItem instance that was the
                                                    //	target of the event
                        if (oMenuItem) {
                            if ('0' == oMenuItem.value) {   // Add Page
                                <stripes:url var="url" beanclass="foo.bar.wiki.web.action.page.AddPageActionBean" event="view">
                                        <stripes:param name="page" value=""/>
                                        <stripes:param name="page.space" value="${actionBean.space.id}"/>
                                </stripes:url>
                                document.location.href = '${url}';
                            }
                            else if ('1' == oMenuItem.value) { // remove space
                                <stripes:url var="url" beanclass="foo.bar.wiki.web.action.space.RemoveSpaceActionBean" event="remove">
                                    <stripes:param name="space" value="${actionBean.space.id}"/>
                                </stripes:url>
                                document.location.href='${url}';
                            }
                            else if ('2' == oMenuItem.value) { // show as wiki page
                                <stripes:url var="url" beanclass="foo.bar.wiki.web.action.space.EditSpaceActionBean" event="view">
                                    <stripes:param name="space" value="${actionBean.space.id}"/>
                                </stripes:url>
                                document.location.href='${url}';
                            }
                            else if ('3' == oMenuItem.value) { // atom 1.0
                                <stripes:url var="url" beanclass="foo.bar.wiki.web.action.general.SpaceFeedsActionBean" event="view">
                                    <stripes:param name="space" value="${actionBean.space.id}"/>
                                    <stripes:param name="feedType" value="atom_1_0" />
                                </stripes:url>
                                document.location.href='${url}';
                            }
                            else if ('4' == oMenuItem.value) { // rss 2.0
                                <stripes:url var="url" beanclass="foo.bar.wiki.web.action.general.SpaceFeedsActionBean" event="view">
                                    <stripes:param name="space" value="${actionBean.space.id}"/>
                                    <stripes:param name="feedType" value="rss_2_0" />
                                </stripes:url>
                                document.location.href='${url}';
                            }
                            else {
                                alert('unrecognized menu option');
                            }
                        }
                    };
                    //	Add a "click" event listener for the Button's Menu
                    manageHeaderMenu.getMenu().subscribe("click", onMenuClick);
                });
        </script>
    </stripes:layout-component>


    <stripes:layout-component name="_topNav">
        <H1>Space [${actionBean.space.name}]</H1>
        <UL class="gc-topnav-tabs">
            <LI>
                <span id="spaceHeaderMenu">
                <input type="button" id="spaceHeaderMenuButton" value="Options"/>
                <select id="spaceHeaderMenuButtonSelect">
                    <jsecurity:hasPermission name="space:addPage:${actionBean.space.id}">
                        <option value="0">Add Page</option>
                        <option value="x">&nbsp;</option>
                    </jsecurity:hasPermission>
                    <jsecurity:hasPermission name="space:removeSpace:${actionBean.space.id}">
                        <option value="1">Delete Space</option>
                        <option value="x">&nbsp;</option>
                    </jsecurity:hasPermission>
                    <foobarwiki:hasAnyPermissions name="space:viewSpace:${actionBean.space.id}|space:editSpace:${actionBean.space.id}">
                        <option value="2">Manage Space</option>
                        <option value="x">&nbsp;</option>
                    </foobarwiki:hasAnyPermissions>
                    <jsecurity:hasPermission name="space:viewSpace:${actionBean.space.id}">
                        <option value="3">ATOM 1.0</option>
                        <option value="x">&nbsp;</option>
                        <option value="4">RSS 2.0</option>
                    </jsecurity:hasPermission>
                </select>
                </span>
            </LI>
        </UL>
    </stripes:layout-component>
    


    <stripes:layout-component name="_content">
        <stripes:errors/>
        <stripes:messages/>
        <jsecurity:hasPermission name="space:viewSpaceAsWiki:${actionBean.space.id}">
        <p>
            This is the deault page for space [${actionBean.space.name}] when there's no default page
            being defined for this space.
        </p>
        <p>
            The default page can be mark by navigating to the page itsef and from
            the option button drop down menu on the top right of the screen choose the menu item 'Make As Default Page'.
            This will make this particular page the default page for this space. Do not that there can only be one
            default page for each space, making another page as default page will override the previously marked
            default page.
        </p>
        <p/><p/>
        <h2>Description</h2>
        <p>
            Following is the description for this space :-
        </p>
        <p>
           ${actionBean.space.description} 
        </p>
        <p/><p/>

        <h2>Pages</h2>
        <p>
            Following are the pages of this space.
        </p>
        <p/>
        <p/>
        <stripes:url var="url" beanclass="foo.bar.wiki.web.action.space.SpaceActionBean" event="view">
            <stripes:param name="space" value="${actionBean.space.id}"/>    
        </stripes:url>
        <displaytag:table id="element" name="${actionBean.pages}"
                                  sort="external"
                                  excludedParams="*"
                                  defaultsort="1"
                                  defaultorder="ascending"
                                  requestURI="${url}"
                                  requestURIcontext="true" style="width:100%" >
                    <displaytag:column property="name" sortable="false" sortName="name" title="Name" />
                    <displaytag:column property="description" sortable="false" sortName="description" title="Description" />
                    <displaytag:column property="creator.username" sortable="false" sortName="creator" title="Creator"/>
                    <displaytag:column title="Creation Date">
                        <fmt:formatDate value="${element.creationDate}" pattern="dd/MM/yyyy hh:mm:ss a"/>
                    </displaytag:column>
                    <displaytag:column property="modifier.username" sortable="false" sortName="username" title="Modifier"/>
                    <displaytag:column title="Modification Date">
                        <fmt:formatDate value="${element.modificationDate}" pattern="dd/MM/yyyy hh:mm:ss a"/>
                    </displaytag:column>
                    <displaytag:column title="Actions">
                        <stripes:link class="_view" beanclass="foo.bar.wiki.web.action.page.PageActionBean" event="view">
                            <stripes:param name="page" value="${element.id}"/>
                            View
                        </stripes:link>
                    </displaytag:column>
                </displaytag:table>
        </jsecurity:hasPermission>
        <jsecurity:lacksPermission name="space:viewSpaceAsWiki:${actionBean.space.id}">
            Lacks "space:viewSpaceAsWiki:${actionBean.space.id}" permissions
        </jsecurity:lacksPermission>
    </stripes:layout-component>
</stripes:layout-render>


